package tp.pr2;

public class CodeCard  extends Item{
    private java.lang.String code;
	
	
	public CodeCard(java.lang.String id, java.lang.String description, java.lang.String code)
	{
	super(id,description);	
	this.code=code;		
	}
	
	public boolean canBeUsed()
	{
	 return true;	
	}
	
	public boolean use(RobotEngine r, Place p)
	{ 
		if(r.getHeadingStreet()!=null)
		{	
		 if(r.getHeadingStreet().compareCode(this))
		   {
		     if(!r.getHeadingStreet().isOpen()) r.getHeadingStreet().open(this);
		     else r.getHeadingStreet().close(this);
		     return true;
		   }
		}
		return false;
	}
	
	public java.lang.String getCode()
	{
		return code;
	}
	
}
